#include "fileimpl.h"

CFileImpl::CFileImpl(void)
{
	m_hFile = FILE_INVALID;
}
CFileImpl::~CFileImpl(void)
{

}
std_method_impl CFileImpl::LoadFile(const TCHAR* pszLoadFile,
										  unsigned long ulwDesiredAccess,
										  unsigned long ulShareMode,
										  unsigned long ulCreationDisposition,
										  unsigned long ulFlagsAndAttributes)
{
	HRESULT		hr	=	S_OK;
	m_hFile = _file_open(pszLoadFile, O_RDWR, 0644);
	return hr;
}
std_method_impl CFileImpl::CloseFile()
{
	HRESULT		hr	=	S_OK;
	_file_close(m_hFile);
	return hr;
}
std_method_type_impl(int64) CFileImpl::GetFileSize()
{
	return _file_fsize(m_hFile);
}

std_method_impl CFileImpl::ReadBuffer(char* szBuffer,int64 ulReadFileLen, int64* ulReadSize)
{
	HRESULT		hr	=	S_OK;

	size_t size = ulReadFileLen & UINT32_MAX;

	*ulReadSize = _file_read(m_hFile, szBuffer, size);

	return hr;
}
std_method_impl CFileImpl::WriteBuffer(char* szBuffer, int64 ulWriteSize)
{
	HRESULT		hr = S_OK;

	size_t size = ulWriteSize & UINT32_MAX;

	_file_write(m_hFile, szBuffer, size);

	return hr;
}
